package cn.edu.scau.cmi.chensicheng.client;

import cn.edu.scau.cmi.chensicheng.singleton.Chairman;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class SingletonClient extends Application{
	
	@Override
	public void start(Stage primaryStage) {
		Text createText = new Text();
		Button createButton = new Button("一键添加主席");
		createButton.setOnAction(e->{
			Chairman.getInstance("毛泽东");
			createText.setText("添加成功！");
		});
		Text printText = new Text();
		Button printButton = new Button("输出所有主席");
		printButton.setOnAction(e->{
			printText.setText(Chairman.getInstance("毛泽东").getName());
		});
		Button clearButton = new Button("清空信息");
		clearButton.setOnAction(e->{
			createText.setText("");
			printText.setText("");
		});
		VBox vBox = new VBox(20,createButton,printButton,clearButton,createText,printText);
		vBox.setAlignment(Pos.CENTER);
		Scene scene = new Scene(vBox,300,300);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}

}
